package com.porinkey.geotan;


import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.util.DisplayMetrics;

public class MapSmallRow {
	
	private String _viewPath;
	private DisplayMetrics _metrix;
	
	public MapSmallRow(String path){
		this._viewPath = path;
	}
	
	public void setDisplayMetrix(DisplayMetrics metrix ){
		this._metrix = metrix;
	}

	public String getPath(){
		return _viewPath;
	}
	
	public Bitmap getSmallImage(){
		Bitmap bt = decodeLargeFile(this._viewPath);
		return bt;
	}
	
	public Bitmap decodeLargeFile(String path) {
		BitmapFactory.Options options = new BitmapFactory.Options();
		
		options.inJustDecodeBounds = true;
		BitmapFactory.decodeFile(path, options);
		
		int width = 320;
		int height = 240;
		
		if(this._metrix != null){
			width = this._metrix.widthPixels;
			height = this._metrix.heightPixels;
		}
		int scaleW = options.outWidth / width + 1;
		int scaleH = options.outHeight / height + 1;

		int scale = Math.max(scaleW, scaleH);

		options.inJustDecodeBounds = false;
		options.inSampleSize = scale;

		return BitmapFactory.decodeFile(path, options);
	}
	
	
}
